#include<iostream>
using namespace std;
bool check(int x)
{
	while (x) {
		int t = x % 16;
		x /= 16;
		if (t < 10)return 0;
	}
	return 1;
}
int main()
{
	int ans = 0;
	for (int i = 2023;; i++) {
		if (check(i)) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}